<nz-collapseset>
  <nz-collapse [nzTitle]="panels.name" [nzActive]="panels.active" [nzDisabled]="panels.disabled">
    <form nz-form>
      <div nz-form-item nz-row style="margin-bottom: 12px">
        <div nz-form-label nz-col  [nzSpan]="2">
          <label>使用单位</label>
        </div>
        <div nz-form-control nz-col [nzSpan]="3">
          <nz-input [(ngModel)]="demandMaintenance.userPartyName" name="planName">
          </nz-input>
        </div>

        <div nz-form-label nz-col  [nzSpan]="2">
          <label>维保单位</label>
        </div>
        <div nz-form-control nz-col [nzSpan]="3">
          <nz-input [(ngModel)]="demandMaintenance.maintenancePartyName" name="planName">
          </nz-input>
        </div>

        <div nz-form-label nz-col [nzSpan]="2">
          <label>实施时间</label>
        </div>
        <div nz-form-control nz-col [nzSpan]="7" >
          <nz-datepicker [nzSize]="'large'" [nzFormat]="'YYYY-MM-DD'" name="startDate" [nzPlaceHolder]="'开始日期'" [(ngModel)]="demandMaintenance.startDate"></nz-datepicker>
          ~
          <nz-datepicker [nzSize]="'large'" [nzFormat]="'YYYY-MM-DD'" name="endDate" [nzPlaceHolder]="'结束日期'" [(ngModel)]="demandMaintenance.endDate"></nz-datepicker>
        </div>

        <button [nzSize]="'large'" nz-button  [nzType]="'primary'" (click)="query()">查询</button>
      </div>
    </form>
  </nz-collapse>
</nz-collapseset>
<div>
   <ul nz-menu [nzMode]="'horizontal'">
    <li *ngIf="partyType=='2'" nz-menu-item (click)="add(title, content, footer)">
      <i class="anticon anticon-plus"></i>添加</li>
    <li *ngIf="partyType=='2'" nz-menu-item (click)="update(title, content, footer)">
      <i class="anticon anticon-copy"></i>详情/修改</li>
    <li *ngIf="partyType=='2'" nz-menu-item (click)="delete()">
      <i class="anticon anticon-delete"></i>删除</li>
     <li *ngIf="partyType=='2'" nz-menu-item (click)="submit()">
       <i class="anticon anticon-copy"></i>提交审批</li>
  </ul>

  <nz-table #nzTable [nzDataSource]="dataList" nzSize="middle" [nzBordered]="true" [nzIsPagination]="false" (nzDataChange)="displayDataChange($event)">
    <thead nz-thead>
    <tr>
      <th nz-th [nzCheckbox]="true">
        <label nz-checkbox [(ngModel)]="allChecked" [nzIndeterminate]="indeterminate" (ngModelChange)="checkAll($event)">
        </label>
      </th>
      <th nz-th>
        <span>使用单位</span>
      </th>
      <th nz-th>
        <span>维保单位</span>
      </th>
      <th nz-th>
        <span>保险单位</span>
      </th>
      <th nz-th>
        <span>保险到期时间</span>
      </th>
      <th nz-th>
        <span>申请维保周期</span>
      </th>
      <th nz-th>
        <span>实施时间</span>
      </th>
      <th nz-th>
        <span>申请状态</span>
      </th>
      <th nz-th>
        <span>其他说明</span>
      </th>
      <th nz-th>
        <span>电梯详情</span>
      </th>
      <th *ngIf="partyType != '1'" nz-th>
        <span>下载文件</span>
      </th>
      <th nz-th>
        <span>上传</span>
      </th>
      <th *ngIf="partyType != '1'" nz-th>
        <span>操作</span>
      </th>
    </tr>

    </thead>
    <tbody nz-tbody>
    <tr nz-tbody-tr *ngFor="let data of dataList">
      <td nz-td [nzCheckbox]="true">
        <label nz-checkbox [nzDisabled]="data.disabled" [(ngModel)]="data.checked" (ngModelChange)="refreshStatus($event)">
        </label>
      </td>
      <td nz-td>{{data.userPartyName}}</td>
      <td nz-td>{{data.maintenancePartyName}}</td>
      <td nz-td>{{data.insuranceName}}</td>
      <td nz-td>{{data.insuranceDate}}</td>
      <td nz-td>{{data.maintenanceCycle}}</td>
      <td nz-td>{{(data.startDate | dateFormat)}} ~ {{(data.endDate | dateFormat)}}</td>
      <td nz-td>{{data.applyStatus | constantTransfer : applyStatus}}</td>
      <td nz-td>{{data.otherNotes}}</td>
      <td nz-td>
        <button nz-button  [nzSize]="'small'" [nzType]="'primary'" (click)="detail(data)">查看</button>
      </td>

      <td nz-td *ngIf="partyType != '1'">
        <span>
          <nz-popover [nzTitle]="'请选择'" [nzPlacement]="'bottom'" [nzTrigger]="'click'">
              <button nz-button [nzSize]="'small'" [nzType]="'primary'" nz-popover>下载</button>
              <ng-template #nzTemplate>
                  <div>
                      <button nz-button [nzSize]="'small'" (click)="downloadFile(data,1)">维保服务申明</button>
                  </div>
                  <div style="margin-top:10px">
                      <button nz-button [nzSize]="'small'" (click)="downloadFile(data,2)">承诺书</button>
                  </div>
              </ng-template>
          </nz-popover>
        </span>
      </td>

      <td nz-td *ngIf="partyType == '1'">
        <button nz-button  [nzSize]="'small'" [nzType]="'primary'" (click)="upload(data,1)">维保服务申明</button>
      </td>
      <td nz-td *ngIf="partyType == '2'">
        <button nz-button  [nzSize]="'small'" [nzType]="'primary'" (click)="upload(data,2)">承诺书</button>
      </td>

      <td nz-td *ngIf="partyType != '1' && data.applyStatus == '2'">
        <button nz-button  [nzSize]="'small'" [nzType]="'primary'" (click)="isSuspend(data)">中止</button>
      </td>
      <td nz-td *ngIf="partyType != '1' && data.applyStatus != '2'">
        <button nz-button  [nzSize]="'small'" [nzType]="'primary'" [disabled]="true" (click)="isSuspend(data)">中止</button>
      </td>
    </tr>
    </tbody>
  </nz-table>

  <nz-pagination [nzPageIndex]="demandMaintenance.currentPage" nzShowTotal [nzTotal]="total" nzShowSizeChanger
                 (nzPageSizeChange)="nzPageSizeChange($event)" (nzPageIndexChange)="nzPageIndexChange($event)"
                 (nzPageIndexClickChange)="nzPageIndexClickChange($event)" [nzPageSize]="demandMaintenance.pageSize"></nz-pagination>

  <nz-modal [nzVisible]="isVisible" [nzTitle]="'文件上传'" [nzOkText]="'确定'" [nzCancelText]="'取消'" [nzContent]="modalContent"
            (nzOnCancel)="isVisible=false" (nzOnOk)="isVisible=false">
    <ng-template #modalContent>
      <!--
            <nz-spin [nzTip]="'正在上传请等待...'" [nzSpinning]="nzSpinning1">
      -->
      <nz-upload *ngIf="uploadType==1" nzAction="{{config.IP+config.API.upload}}" nzListType="text"
                 [(nzFileList)]="maintanceFileList" [nzShowButton]="true" [nzRemove]="nzRemoveFile"
                 (nzChange)="uploadChange($event)">
        <button nz-button>
          <i class="anticon anticon-upload"></i>
          <span>上传维保单位服务申明</span>
        </button>
      </nz-upload>

      <nz-upload *ngIf="uploadType==2" nzAction="{{config.IP+config.API.upload}}" nzListType="picture-card"
                 [(nzFileList)]="letterFileList" [nzShowButton]="true" [nzRemove]="nzRemoveFile"
                 (nzChange)="nzChangeFile($event)">
        <i class="anticon anticon-plus"></i>
        <div class="ant-upload-text">上传承诺书图片</div>
      </nz-upload>
      <div style="text-align: center;margin-top: 30px;">
        <button nz-button [nzSize]="'large'" (click)="updateUpload()" [nzType]="'primary'">确定上传</button>
      </div>
      <!--
            </nz-spin>
      -->
    </ng-template>
  </nz-modal>
  <!--添加页面 -->
  <ng-template #title>
    <span>{{modelTitle}}</span>
  </ng-template>
  <ng-template #content>
    <demandMaintenance-add (outValue)="addCall($event) " *ngIf="modal==0"></demandMaintenance-add>
    <demandMaintenance-update (outValue)="addCall($event) " *ngIf="modal==1" [inValue]="updateData"></demandMaintenance-update>
  </ng-template>
  <ng-template #footer>
    <div>
    </div>
  </ng-template>

</div>
